package cn.wolfcode.mapper;

import cn.wolfcode.domain.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
/**
 * @author liuquan
 * @program: mybatis-plus
 * @description: mapper接口
 * @date 2021-01-31 10:09:49
 */
public interface EmployeeMapper extends BaseMapper<Employee> {
    List<Employee> listByXmlSingle();


    //查询员工并查询该员工对应部门信息
    List<Employee> listByXmlJoin();

    @Select("select e.* from employee e")
    List<Employee> listByAnnoSingle();


    @Select("select e.*, d.id d_id, d.name d_name, d.sn d_sn from employee e left join department d on e.dept_id = d.id")
    @Results({
            @Result(column="d_id", property = "dept.id"),
            @Result(column="d_name", property = "dept.name"),
            @Result(column="d_sn", property = "dept.sn")
    })
    List<Employee> listByAnnoJoin();
}
